package com.atguigu.guli.service.expriton;

import com.atguigu.guli.service.result.R;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.ibatis.reflection.ExceptionUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Configuration
public class GoldExprtion {
    //这个注解就是开启异常处理
    @ExceptionHandler(value = Exception.class)
    public R exception(Exception e){
        System.out.println(ExceptionUtils.getStackTrace(e)); //打印异常的状态信息
        return R.error();
    }
}
